﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EMall.ProductService.ProductSkus
{
    public class ProductSkuEntityTypeConfiguration : IEntityTypeConfiguration<ProductSku>
    {
        public void Configure(EntityTypeBuilder<ProductSku> builder)
        {
            builder.ToTable("ProductSkus");
            builder.HasKey(p => p.Id);
            builder.Property(p => p.ProductId).IsRequired();
            builder.Property(p => p.Spec).IsRequired();
            builder.Property(p => p.CostPrice).IsRequired().HasDefaultValue(0m);
            builder.Property(p => p.SalePrice).IsRequired().HasDefaultValue(0m);
            builder.Property(p => p.AvailableStock).IsRequired().HasDefaultValue(0);
        }
    }
}